package controller;

import java.util.ArrayList;
import java.util.List;

public class Pool {

	String poolName = "NO_NAME";
	List<PoolItem> listItem = new ArrayList<PoolItem>();

	public Pool() {
	};

	public Pool(String name) {
		poolName = name;
	};

	public boolean insertPoolItem(int itemId, int referencedObjectId) {
		return listItem.add(new PoolItem(itemId, System.currentTimeMillis(), referencedObjectId));
	}

	public PoolItem getAndRemoveOlder() {
		if (listItem.size() > 0) {
			PoolItem pi = listItem.get(0);
			listItem.remove(0);
			return pi;
		} else {
			return null;
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Pool [poolName=" + poolName + ", listItem=" + listItem + "]";
	}
}
